package com.nanhai.buddhist.college.module.collegebase.dal.mysql.textbookinfo;

import java.util.*;

import com.nanhai.buddhist.college.framework.common.pojo.PageResult;
import com.nanhai.buddhist.college.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.nanhai.buddhist.college.framework.mybatis.core.mapper.BaseMapperX;
import com.nanhai.buddhist.college.module.collegebase.controller.admin.textbookinfo.type.vo.TextbookTypeExportReqVO;
import com.nanhai.buddhist.college.module.collegebase.controller.admin.textbookinfo.type.vo.TextbookTypePageReqVO;
import com.nanhai.buddhist.college.module.collegebase.dal.dataobject.textbooktype.TextbookTypeDO;
import org.apache.ibatis.annotations.Mapper;

/**
 * 教材分类 Mapper
 *
 * @author AKai
 */
@Mapper
public interface TextbookTypeMapper extends BaseMapperX<TextbookTypeDO> {

    default PageResult<TextbookTypeDO> selectPage(TextbookTypePageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<TextbookTypeDO>()
                .likeIfPresent(TextbookTypeDO::getTypeName, reqVO.getTypeName())
                .eqIfPresent(TextbookTypeDO::getParentId, reqVO.getParentId())
                .betweenIfPresent(TextbookTypeDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(TextbookTypeDO::getCreateTime));
    }

    default List<TextbookTypeDO> selectList(TextbookTypeExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<TextbookTypeDO>()
                .likeIfPresent(TextbookTypeDO::getTypeName, reqVO.getTypeName())
                .eqIfPresent(TextbookTypeDO::getParentId, reqVO.getParentId())
                .betweenIfPresent(TextbookTypeDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(TextbookTypeDO::getCreateTime));
    }

    default PageResult<TextbookTypeDO> selectTreePage(TextbookTypePageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<TextbookTypeDO>()
                .likeIfPresent(TextbookTypeDO::getTypeName, reqVO.getTypeName())
                .eqIfPresent(TextbookTypeDO::getParentId,"0")
                .betweenIfPresent(TextbookTypeDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(TextbookTypeDO::getCreateTime));
    }
}
